package com.example.badyloans.config;

import com.example.badyloans.Handler.SessionHandler;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author 啊桥哦
 * @Description:
 * @date 2020-07-14 9:27
 */
@Configuration
public class WebConfiguration implements WebMvcConfigurer {
    @Resource
    private SessionHandler sessionHandler;
    /**
     * 配置虚拟路径
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/avatar/**").
                addResourceLocations("file:D:/badyloans/src/main/resources/static/avatar/");
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //指定拦截器
        registry.addInterceptor(sessionHandler)
                //指定需要拦截的路劲
                .addPathPatterns("/**")
                //指定不拦截路劲
                .excludePathPatterns("/admin/login.html","/zhuxiao","/login.html","/js/login.html/","/js/plugins/jquery-validation/localization/login.html","/user/login.html")
                .excludePathPatterns("/css/**","/js/**","/images/**","/user/login","/","/error")
                .excludePathPatterns("/tpl-head.html","/tpl-navbar.html","/tpl-footer.html","/finance/borrow/query","/index.html");
    }
}


